﻿<Window x:Class="HashCalculator.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converter="clr-namespace:HashCalculator.Converters"
    Title="Hash Calculator" SizeToContent="Height" Width="395" ResizeMode="CanMinimize" 
        WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" 
        AllowDrop="True" PreviewDragEnter="Window_DragEnter" PreviewDrop="Window_Drop">
    
    <Window.Resources>
        <converter:BooleanInvertConverter x:Key="invertConverter"/>
    </Window.Resources>
    
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo ProgressValue="{Binding ProgressValue}" ProgressState="Normal">
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfoCollection>
                    <ThumbButtonInfo Command="{Binding CancelCommand}" Description="Cancel">
                        <ThumbButtonInfo.ImageSource>
                            <DrawingImage>
                                <DrawingImage.Drawing>
                                    <DrawingGroup>
                                        <GeometryDrawing Brush="DarkSlateGray">
                                            <GeometryDrawing.Geometry>
                                                <RectangleGeometry Rect="0,0,20,20"/>
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                        <GeometryDrawing>
                                            <GeometryDrawing.Pen>
                                                <Pen Brush="White" Thickness="2"/>
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <GeometryGroup>
                                                    <LineGeometry StartPoint="5,5" EndPoint="15,15"/>
                                                    <LineGeometry StartPoint="15,5" EndPoint="5,15"/>
                                                </GeometryGroup>
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                    </DrawingGroup>
                                </DrawingImage.Drawing>
                            </DrawingImage>
                        </ThumbButtonInfo.ImageSource>
                    </ThumbButtonInfo>
                </ThumbButtonInfoCollection>
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>
    
    <Grid Margin="10,10,10,10">
        <Grid.Resources>
            <Style TargetType="GroupBox">
                <Setter Property="Margin" Value="0,5,0,5"/>
            </Style>
            <Style TargetType="ProgressBar">
                <Setter Property="Margin" Value="10"/>
                <Setter Property="Height" Value="20"/>
                <Setter Property="Minimum" Value="0"/>
                <Setter Property="Maximum" Value="100"/>
            </Style>
            <Style TargetType="TextBox">
                <Setter Property="Margin" Value="10,0,10,10"/>
                <Setter Property="IsReadOnly" Value="True"/>
            </Style>
            <Style TargetType="TextBlock">
                <Setter Property="Margin" Value="10,10,10,0"/>
            </Style>
            <Style TargetType="Button">
                <Setter Property="Width" Value="75"/>
                <Setter Property="Height" Value="23"/>
            </Style>

            <ToolTip x:Key="ToolTip" DataContext="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget}">
                <TextBlock Text="{Binding Path=Value, StringFormat={}{0}%}" Style="{x:Null}"/>
            </ToolTip>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBox Name="textBoxFilePath" Grid.Column="0" Margin="0,0,5,0" IsEnabled="{Binding IsBusy, Converter={StaticResource invertConverter}}" IsReadOnly="False" Text="{Binding FilePath, UpdateSourceTrigger=PropertyChanged}" ToolTip="{Binding Path=Text, RelativeSource={RelativeSource Self}}" 
                     AllowDrop="True" PreviewDragEnter="Window_DragEnter" PreviewDrop="Window_Drop"/>
            <Button Grid.Column="1" Command="{Binding BrowseCommand}" Width="23" HorizontalAlignment="Left">...</Button>
        </Grid>
        
        <ItemsControl ItemsSource="{Binding Models}" Grid.Row="1">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <GroupBox Header="{Binding Name}">
                        <StackPanel>
                            <ProgressBar Value="{Binding DonePercent}" ToolTip="{StaticResource ToolTip}"/>
                            <TextBox Text="{Binding Result}" />
                        </StackPanel>
                    </GroupBox>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Command="{Binding ComputeCommand}" Margin="0,0,5,0">Compute</Button>
                <Button Command="{Binding CancelCommand}">Cancel</Button>
            </StackPanel>
        </Grid>

        <Expander Header="TXT" Grid.Row="3" Padding="0,5,0,5">
            <StackPanel>
                <TextBox Height="56.88" AcceptsReturn="True" MaxLines="2" MinLines="2" Margin="0,0,0,10" Text="{Binding Result, Mode=OneWay}"/>
                <Button Command="{Binding CopyCommand}" HorizontalAlignment="Left" Margin="0">Copy</Button>
            </StackPanel>
        </Expander>
        
        <TextBlock Grid.Row="4" Margin="0" FontSize="11" Foreground="Gray" HorizontalAlignment="Right">&#x00A9; Kirill Polishchuk</TextBlock>

    </Grid>
</Window>
